//
//  HJBankEmpty.m
//  project
//
//  Created by yefei on 2019/7/31.
//  Copyright © 2019 健健. All rights reserved.
//

#import "HJBankEmpty.h"

@interface HJBankEmpty ()

@property (nonatomic,strong) UIImageView * bgImageView;
@property (nonatomic,strong) UIButton * addBtn;

@end

@implementation HJBankEmpty

+(instancetype)initView {
    HJBankEmpty * empty = [[HJBankEmpty alloc]init];
    return empty;
}
-(instancetype)init {
    if (self == [super init]) {
        [self addSubview:self.bgImageView];
        [self addSubview:self.addBtn];
    }
    return self;
}
-(UIImageView *)bgImageView {
    if (!_bgImageView) {
        _bgImageView = [UIImageView new];
        _bgImageView.image = setImage(@"kapian");
    }
    return _bgImageView;
}
-(UIButton *)addBtn {
    if (!_addBtn) {
        _addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_addBtn setTitleColor:[UIColor colorWithHex:0xffffff] forState:0];
        [_addBtn setBackgroundColor:[UIColor colorWithHex:0x2a2a2a]];
        [_addBtn setTitle:@"+添加银行卡" forState:0];
        [_addBtn setImage:setImage(@"icon_gift_add_bank_card") forState:0];
        @weakify(self)
        [[_addBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self)
            if (self.addDidClickBlock) {
                self.addDidClickBlock();
            }
        }];
    }
    return _addBtn;
}
-(void)layoutSubviews {
    [super layoutSubviews];
    @weakify(self)
    [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        @strongify(self)
        make.centerY.equalTo(self);
        make.centerX.equalTo(self);
        make.size.mas_equalTo(CGSizeMake(self.bgImageView.image.size.width, self.bgImageView.image.size.height));
    }];
    
    [self.addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        @strongify(self)
        make.top.equalTo(self.bgImageView.mas_bottom).offset(47);
        make.left.equalTo(self).offset(34);
        make.right.equalTo(self).inset(34);
        make.height.mas_equalTo(47);
        [self.addBtn rounded:UIRectCornerAllCorners radius:5];
    }];
    
}

@end
